package javase.reflection.generic;

import java.lang.reflect.Field;
import java.lang.reflect.Type;

public class GenericInfoPrinter {
    private final static String FIELD_NAME = "value";

    public <T> void printInforAboutGenericType(SomeGeneric<T> generic) {
	try {
	    Field field = generic.getClass().getDeclaredField(FIELD_NAME);
	    Type type = field.getGenericType();
	    System.out.println("Generic type is " + type);
	} catch (SecurityException e) {
	   System.out.println("can't get field");
	} catch (NoSuchFieldException e) {
	    System.out.println("field " + FIELD_NAME + " is missing in class" + generic.getClass().getCanonicalName());
	}
    }
}
